package com.whisper.application.service.service.impl;

import com.whisper.application.service.domain.VrArt;
import com.whisper.application.service.mapper.VrArtMapper;
import com.whisper.application.service.service.IVrArtService;
import com.whisper.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.whisper.common.security.util.SecurityUtils.getUsername;

/**
 * 文章Service业务层处理
 * 
 * @author whisper
 * @date 2024-01-07
 */
@Service
public class VrArtServiceImpl implements IVrArtService 
{
    @Autowired
    private VrArtMapper vrArtMapper;

    /**
     * 查询文章
     * 
     * @param id 文章主键
     * @return 文章
     */
    @Override
    public VrArt selectVrArtById(Long id)
    {
        return vrArtMapper.selectVrArtById(id);
    }

    /**
     * 查询文章列表
     * 
     * @param vrArt 文章
     * @return 文章
     */
    @Override
    public List<VrArt> selectVrArtList(VrArt vrArt)
    {
        return vrArtMapper.selectVrArtList(vrArt);
    }

    /**
     * 新增文章
     * 
     * @param vrArt 文章
     * @return 结果
     */
    @Override
    public int insertVrArt(VrArt vrArt)
    {
        vrArt.setCreateTime(DateUtils.getNowDate());
        vrArt.setCreateBy(getUsername());
        return vrArtMapper.insertVrArt(vrArt);
    }

    /**
     * 修改文章
     * 
     * @param vrArt 文章
     * @return 结果
     */
    @Override
    public int updateVrArt(VrArt vrArt)
    {
        vrArt.setUpdateTime(DateUtils.getNowDate());
        vrArt.setUpdateBy(getUsername());
        return vrArtMapper.updateVrArt(vrArt);
    }

    /**
     * 批量删除文章
     * 
     * @param ids 需要删除的文章主键
     * @return 结果
     */
    @Override
    public int deleteVrArtByIds(Long[] ids)
    {
        return vrArtMapper.deleteVrArtByIds(ids);
    }

    /**
     * 删除文章信息
     * 
     * @param id 文章主键
     * @return 结果
     */
    @Override
    public int deleteVrArtById(Long id)
    {
        return vrArtMapper.deleteVrArtById(id);
    }

    @Override
    public List<VrArt> selectVrArtOrderByCreateTimeLimit(Integer limit) {
        return vrArtMapper.selectVrArtListByCreateTimeLimit();
    }

    @Override
    public List<VrArt> selectVrArtListLimit(VrArt vrArt, Integer i) {
        return vrArtMapper.selectVrArtListLimit(vrArt, i);
    }
}
